package com.gitee.jiaojinxin.oauth2.auth.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;

import java.util.Map;

@Configuration
public class MyTokenEnhancer implements TokenEnhancer {
    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        Map<String, Object> addInfo = accessToken.getAdditionalInformation();
        addInfo.put("自定义附加", "我是自定义附加信息");
        ((DefaultOAuth2AccessToken)accessToken).setAdditionalInformation(addInfo);
        return accessToken;
    }
}
